<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="wangyuguo">
		<title>编辑消费折扣特殊规则</title>
		<script type="text/javascript" language="JavaScript" src="../script/common.js"></script>
		<script language="javascript" src="../script/core/mootools.js" type="text/javascript"></script>
		<script type="text/javascript" language="JavaScript" src="../script/tree.js"></script>
		<script type="text/javascript" language="JavaScript">
			var qt = null;
			
			function load() {
				var result = DWR.syncCall("zhgjService.findCardTypes")
				Common.initDict(ruleForm.cardType,result,"(不限制)","id","name");
				
			}

			function onSave() {
            	if (!checkForm(ruleForm)) return;
				var obj = Common.getValues(ruleForm);
				if (!obj.cardType && !obj.amountLimit)
				{
					showInformation("至少需要输入一个判断条件")
					return
				}
				if (obj.amountLimit)
					obj.amountLimit = obj.amountLimit * 100 
				if (!obj.discountRate && !obj.discountAmount)
				{
					showInformation("至少需要输入一个执行结果")
					return
				}
				if (obj.discountRate && obj.discountAmount)
				{
					showInformation("只能有一个执行结果")
					return
				}
				obj.resultType = null
				if (obj.discountAmount)
					obj.discountAmount = obj.discountAmount * 100
				if (obj.discountRate)
					obj.discountRate = (new Number(obj.discountRate)/100).round(10);
				dialogBackValue(obj);
			}
			
			function changeResultType(){
				var value = Common.getRadioValue('resultType')
				
				if (value=='rate'){
					ruleForm.discountRate.className=""
					ruleForm.discountRate.readOnly=false
					ruleForm.discountRate.focus()
					ruleForm.discountAmount.className="readonly"
					ruleForm.discountAmount.readOnly=true
					ruleForm.discountAmount.value = ""
				}else{
					ruleForm.discountRate.className="readonly"
					ruleForm.discountRate.readOnly=true
					ruleForm.discountRate.value = ""
					ruleForm.discountAmount.className=""
					ruleForm.discountAmount.readOnly=false
					ruleForm.discountAmount.focus()
				}
			}
		</script>
	</head>
	<body class="body" onload="load()">
		
		<form id="ruleForm" name="ruleForm">
		
			<div class="form" >
				<div class="formTitle">判断条件</div>
		        <table cellSpacing="0" cellPadding="4" width="100%" border="0">
					<tr>	
						<td>
							<label>消费不低于</label>
							<input type="text" name="amountLimit" maxlength="20" onblur="checkV(this,'amount')"/> 元
						</td>
					</tr>
					<tr>	
						<td>
							<label>卡片类型&nbsp;&nbsp;</label>
							<select name="cardType" ><option></option></select>
						</td>
					</tr>
				</table>
			</div>
			
			<div class="form" >
				<div class="formTitle">执行结果</div>
		        <table cellSpacing="0" cellPadding="4" width="100%" border="0">
				
					<tr>	
						<td>
							<input type='radio' name='resultType' value='rate' checked onclick="changeResultType()"/>
							<label>折&nbsp;扣&nbsp;率</label>
							<input type="text" name="discountRate" maxlength="7" onblur="checkV(this,'double')"/> %
						</td>
					</tr>
					<tr>	
						<td>
							<input type='radio' name='resultType' value='amount' onclick="changeResultType()"/>
							<label>折扣金额</label>
							<input type="text" name="discountAmount" maxlength="20" readonly class="readonly" onblur="checkV(this,'amount')"/> 元
						</td>
					</tr>
				</table>
			</div>
		</form>
	</body>
</html>
